<?php

/**
 * This is the model class for table "{{job}}".
 *
 * The followings are the available columns in table '{{job}}':
 * @property integer $jid
 * @property integer $uid
 * @property string $title
 * @property string $place
 * @property integer $number
 * @property string $pay
 * @property integer $type
 * @property string $stime
 * @property string $etime
 * @property string $createtime
 * @property integer $audit
 * @property string $require
 * @property string $desc
 * @property string $other
 * @property string $contact
 * @property integer $status
 */
class Job extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Job the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{job}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('uid, title, place, number, pay, stime, etime, createtime, require, desc, contact', 'required'),
			array('uid, number, type, audit, status', 'numerical', 'integerOnly'=>true),
			array('title', 'length', 'max'=>255),
			array('place, pay', 'length', 'max'=>64),
			array('stime, etime', 'length', 'max'=>20),
			array('createtime', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('jid, uid, title, place, number, pay, type, stime, etime, createtime, audit, require, desc, other, contact, status', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
            'user'=>array(self::BELONGS_TO, 'User', 'uid'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'jid' => 'Jid',
			'uid' => 'Uid',
			'title' => '招聘职位',
			'place' => '工作地点',
			'number' => '招聘人数',
			'pay' => '薪资待遇',
			'type' => '工作性质',
			'stime' => '招聘开始时间',
			'etime' => '招聘结束时间',
			'createtime' => '招聘发布时间',
			'audit' => '审核状态',
			'require' => '职位要求',
			'desc' => '职责描述',
			'other' => '其它说明',
			'contact' => '联系方式',
			'status' => '状态',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('jid',$this->jid);
		$criteria->compare('uid',$this->uid);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('place',$this->place,true);
		$criteria->compare('number',$this->number);
		$criteria->compare('pay',$this->pay,true);
		$criteria->compare('type',$this->type);
		$criteria->compare('stime',$this->stime,true);
		$criteria->compare('etime',$this->etime,true);
		$criteria->compare('createtime',$this->createtime,true);
		$criteria->compare('audit',$this->audit);
		$criteria->compare('require',$this->require,true);
		$criteria->compare('desc',$this->desc,true);
		$criteria->compare('other',$this->other,true);
		$criteria->compare('contact',$this->contact,true);
		$criteria->compare('status',$this->status);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}